<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="test"></div>
    <script src="../lib//react.development.js"></script>
    <script src="../lib/react-dom.development.js"></script>
    <script src="../lib/babel.min.js"></script>

    <!-- 限制类型 -->
    <script src="../lib/prop-types.js"></script>
    <script type="text/babel">
        // 函数式组件没有 this，没法使用 state、refs，可以使用 props
        // 新版本有 hooks
        const p = { name: 'xm2', age: 17, gender: 'male' }
        function Card({ name, age, gender }){
            return <ul key={name}>
                        <li>姓名：{name}</li>
                        <li>年龄：{age}</li>
                        <li>性别：{gender}</li>
                    </ul>
        }
         // 属性类型限制
         Card.propTypes = {
            name: PropTypes.string.isRequired, // 必填
            gender: PropTypes.string,
            age: PropTypes.number,
            click: PropTypes.func // 函数
        }
        // 默认值
        Card.defaultProps = {
            gender: 'female',
            age: 19
        }

        ReactDOM.render(<Card name="xm3" click={()=>{console.log(111)}}/>, document.getElementById('test'))
    </script>
</body>

</html>